package ch07_reflection.base;

import org.junit.Test;

import java.lang.reflect.Field;

/**
 * 
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class MainTest {
    /**
     * 属性描述：姓名
     */
    private final String name="aa";

    public static void main(String[] args) throws Exception {
        Class<MainTest> mainTestClass = MainTest.class;
        MainTest o = mainTestClass.getConstructor().newInstance();
        Field name = mainTestClass.getField("name");
        name.setAccessible(true);
        name.set(o,"bb");
        System.out.println(o.name);
    }
}
